import { Component, OnInit } from '@angular/core';
import { HttpService, PagedResultDto, PagerSearchInput } from '../../..';


@Component({
  selector: 'app-score-manager',
  templateUrl: './score-manager.component.html',
  styleUrls: ['./score-manager.component.scss']
})
export class ScoreManagerComponent implements OnInit {
  /**
   * 分页数据属性
   */
  listEntities = new PagedResultDto<any>(0, 0, 1, 10, new Array<any>());

  getIndex(index: number) {
    index += 1;
    let reslut = index > 4 ? index % 4 : index;
    reslut = reslut === 0 ? reslut + 1 : reslut;
    return reslut;
  }

  constructor(
    private http: HttpService
  ) {

  }

  ngOnInit() {
    this.getData();
  }


  async getData() {
    const searchBody = new PagerSearchInput(
      this.listEntities.currentPageIndex,
      this.listEntities.pageSize,
      [],
      []);
    this.listEntities = await this.http.post<PagedResultDto<any>>('teacherinfo/TeacherProjectPager', searchBody);
    this.listEntities.entities.forEach(e => e['shadow'] = false);
  }

  hover(j) {
    for (let i = 0; i < this.listEntities.entities.length; i++) {
      if (i !== j) {
        this.listEntities.entities[i].shadow = true;
      }
    }
  }
  leave(j) {
    for (let i = 0; i < this.listEntities.entities.length; i++) {
      this.listEntities.entities[i].shadow = false;
    }
  }

}
